
#include <gtest/gtest.h>
#include "doc_manager.h"

TEST(DocManager, WriteDoc)
{
    DocManager docMgr;

    std::string db = "test_doc.db";
    std::string title = "abc";
    std::string body = "123";

    std::remove(db.c_str());

    docMgr.LoadDB(db);
    int docID = docMgr.GetDocID(title);
    ASSERT_EQ(docID, 0);

    docMgr.WriteDoc(title, body);
    docID = docMgr.GetDocID(title);
    ASSERT_EQ(docID, 1);
    ASSERT_EQ(docMgr.GetTitle(docID), "abc");
    ASSERT_EQ(docMgr.GetBody(docID), "123");
}
